
import java.util.*;
import java.util.List;


 //Definition for a binary tree node.

class Solution {
    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode() {}
        TreeNode(int val) { this.val = val; }
        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

    public List<Integer> preorderTraversal(TreeNode root) {
        List<Integer>list=new ArrayList<>();
        if(root==null) {
            return list;
        }
        preorderTraversal(root.left);
        preorderTraversal(root.right);
        return list;
    }
    public class Test {
        //获取叶子节点的个数
        int count=0;
        public int getLeafNodeCount(TreeNode root) {
            if (root == null) {
                return 0;
            }
            if(root.left==null&&root.right==null){
                count++;
            }
            getLeafNodeCount(root.left);
            getLeafNodeCount(root.right);
            return count;
        }

    }

    public int getHeight(TreeNode root){
        if(root==null){
            return 0;
        }
        int leftHeight=getHeight(root.right);
        int rightHeight=getHeight(root.left);

        return leftHeight>rightHeight?leftHeight+1:rightHeight+1;
    }

    // 检测值为value的元素是否存在
    public TreeNode find(TreeNode root, char val){
        if(root==null){
            System.out.println("不存在你要找的节点");
            return null;
        }
        if(root.val==val){
            return root;
        }
        TreeNode ret1=find(root.left,val);
        if(ret1!=null){
            return ret1;
        }
        TreeNode ret2=find(root.right,val);
        if(ret2!=null){
            return ret2;
        }
        return null;

    }
    //层序遍历
     public void levelOrder(TreeNode root){

     }
    // 判断一棵树是不是完全二叉树
    public boolean isCompleteTree(TreeNode root){
        return true;
    }


}